<!-- Add Tag Dialog -->
<div bsModal #addTagModal="bs-modal" class="modal fade" id="addTagModal" tabindex="-1" role="dialog" aria-labelledby="addTagModalLabel"
     role="dialog" aria-hidden="true" (onShown)="doSelect()" [config]="{ backdrop: true }"
     (onHidden)="close()" *ngIf="isOpen()">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" aria-hidden="true" (click)="cancel()">
                    <span class="pficon pficon-close"></span>
                </button>
                <h4 class="modal-title" id="addTagModalLabel">Add Tag</h4>
            </div>
            <div class="modal-body">
                <p>Enter information about the new tag below and then click <strong>Add</strong>.</p>
                <form id="addtag-form" class="form-horizontal" (submit)="add()" #addTagForm="ngForm" data-dismiss="modal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label required" for="tag">Tag</label>
                        <div class="col-sm-10">
                            <input #addTagInput name="tag" type="text" id="tag" class="form-control" placeholder="Tag Name"
                                   required [(ngModel)]="tag" (ngModelChange)="tagExists = tags.indexOf($event) != -1" #name="ngModel">
                            <div class="form-error-message error" *ngIf="tagExists">Tag already exists.</div>
                            <form-error-message [inputModel]="name" [type]="'required'">Name is required.</form-error-message>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="description">Description</label>
                        <div class="col-sm-10">
                            <textarea name="description" id="description" class="form-control" autosize
                                      placeholder="Tag description" [(ngModel)]="description"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="notice-of-required modal-notice-of-required">The fields marked with <span class="required-icon">*</span> are required.</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" (click)="add()" [disabled]="!addTagForm.form.valid || tagExists">Add</button>
                <button type="button" class="btn btn-default" (click)="cancel()">Cancel</button>
            </div>
        </div>
    </div>
</div>
